Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint rule to detect components contains prop href but not rel #3272

Merged
merged 17 commits into from
Apr 10, 2020

Conversation

Marvin9
Copy link
Contributor

@Marvin9 Marvin9 commented Apr 7, 2020

Summary

First step to solve #3258 .
audit components containing bug.

Assuming all EUI components are functional component.

Checklist

- [ ] Check against all themes for compatibility in both light and dark modes
- [ ] Checked in mobile
- [ ] Checked in IE11 and Firefox
- [ ] Props have proper autodocs
- [ ] Added documentation examples

  • Added or updated jest tests
    - [ ] Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
    - [ ] A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@chandlerprall chandlerprall self-assigned this Apr 7, 2020
Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I think this is a good proxy for the issue, I couldn't find any affected components that this missed. Do you want to fix up the identified components as well? EuiLink and EuiButton are good examples.

For merging, we either need this PR to fix the components, or comment out the rule in .eslintplugin.js or make a follow up PR.

@Marvin9 Marvin9 requested a review from chandlerprall April 8, 2020 06:17
@Marvin9
Copy link
Contributor Author

Marvin9 commented Apr 8, 2020

I want to fix up identified components 🤤 with help of your guidance.

@chandlerprall
Copy link
Contributor

Sounds good! Your changes to EuiBadge look correct, which leaves

  • src/components/header/header_logo.tsx
  • src/components/key_pad_menu/key_pad_menu_item.tsx*
  • src/components/list_group/list_group_item.tsx
  • src/components/side_nav/side_nav_item.tsx
  • src/components/side_nav/side_nav.test.tsx

The first 3 should have rel and target available on their props already through the TypeScript definitions, but EuiSideNavItem will need these added. Then those values will need to be passed to getSecureRel to get the desired rel value.

src/components/side_nav/side_nav.test.tsx is a test file and can be ignored with a // eslint-disable-next-line local/href-with-rel comment

@Marvin9
Copy link
Contributor Author

Marvin9 commented Apr 8, 2020

I couldn't figure out why rel is empty in EuiSideNav snapshot

@Marvin9
Copy link
Contributor Author

Marvin9 commented Apr 9, 2020

@chandlerprall Can you please check this?

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me; please re-enable the rule, and then there's one more change necessary:

src/components/side_nav/side_nav.test.tsx line 113 will need to disable the eslint rule:

        // eslint-disable-next-line local/href-with-rel
        const renderItem: RenderItem<{}> = ({ href, className, children }) => (

.eslintrc.js Outdated Show resolved Hide resolved
@Marvin9 Marvin9 requested a review from chandlerprall April 9, 2020 20:40
Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for solving both sides of the issue!

I added (and fixed a conflict in) the changelog entry since I missed that on my earlier passes

@chandlerprall
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3272/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants